<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
	/* styles.css */

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    padding: 20px;
}

.form-container {
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
}

.info-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.info-table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.info-table label {
    margin-right: 20px; /* 为标签和输入框之间提供间隔 */
}

.info-table tr:last-child td {
    border-bottom: none;
}

.save-button {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    background-color: #6a82fb;
    color: white;
    cursor: pointer;
    transition: background-color 0.3s ease;
    width: 100%;
}

.save-button:hover {
    background-color: #5a74f6;
}
</style>
</head>
<body>
<div class="form-container">
        <form id="providerForm">
            <table class="info-table">
		<tr>
			<td><label>种类编号</label></td>
			<td><label>${provider.providerId }</label></td>
		</tr>
		<tr>
			<td><label for="providerName">种类名称</label></td>
			<td><input type="text" name="providerName" id="providerName" value="${provider.providerName }"></td>
		</tr>
		<tr>
			<td colspan="2"><input type="button" value="保存" id="sub"></td>
		</tr>
		<tr>
			<td colspan="2"><input type="hidden" value="${provider.providerId }" id="id"></td>
		</tr>	
	</table>
	</form>
	</div>
</body>
<script src="../js/jquery.min.js"></script>
<script src="../js/layer/layer.js"></script>
<script>
$(document).ready(function() {
    $('#sub').click(function() {
        var id = $('#id').val();
        var providerName = $('#providerName').val();
        $.post('AdminUpdateProviderServlet', {
            id: id,
            providerName: providerName
        }, function(data) {
            switch(data) {
                case 'OK':
                    layer.msg('修改成功');
                    move();
                    break;
                case 'Error2':
                    layer.alert('供应商名称重复');
                    break;
                default:
                    layer.msg('修改失败');
                    break;
            }
        });
    });
});

function move() {
    window.location.href = 'AdminProviderServlet';
}
</script>
</html>